package news.dao;


import news.model.News;
import news.model.UserCollection;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
@Mapper
public interface UserCollectionDao {
    @Delete("delete from user_collection where news_id = #{newsid} and user_id = #{userId}")
    void delete(@Param("newsid") Integer newsid, @Param("userId") int userId);

    @Insert("insert into user_collection(news_id, user_id, collection_time,news_title)" +
            "values (#{newsid},#{userId},now(),#{title})")
    void insert(@Param("newsid") Integer newsid, @Param("userId") Integer userId,@Param("title")String title);

    @Select("select * from news_info ni left join user_collection uc on uc.news_title = ni.title where uc.user_id=#{userid}")
    List<News> collectionNews(@Param("userid") int userId);

    List<List<News>> commentNews(int userId);
}
